package org.gitos.cloud.domain.comm;


import io.netty.util.AttributeKey;
import org.gitos.cloud.domain.tcp.DeviceId;

/**
 * Constant
 *
 * @author purely
 * @date 2015/12/4
 */
public class Constant {
    /**
     * 运行状态
     */
    public static final Boolean RUN_STATE = true;
    public static final Boolean STOP_STATE = false;

    public static final String MODE_PROD = "prod";
    public static final String MODE_DEV = "dev";

    // ====================配置文件key=============================
    public static final String NODE_ID = "node.id";
    public static final String MODE_KEY = "mode";

    public static final String TCP_PORT = "tcp.port";
    public static final String TCP_IP = "tcp.ip";

    public static final String BOSS_THREAD = "boss.thread";
    public static final String WORK_THREAD = "work.thread";
    public static final String IDLE_READ = "idle.read";

    public static final String ZK_HOSTS = "zk.hosts";
    public static final String zk_PATH = "zk.path";

    // ============================================================

    // sever的交换器
    public static final String SEVER_EXCHANGE = "sever.exchange";
    // comet的交换器
    public static final String COMET_EXCHANGE = "comet.exchange";

    //同步交换器
    public static final String SERVER_SYNC_EXCHANGE = "server.sync.exchange";

    //默认指令
    public static final short CMD_DEFAULT = 0x0f00;
    //==========bucket.cmd设备到comet的指令,comet到服务器的指令=============
    //下发心跳
    public static final short CMD_DOWN_HEART_BEAT = 0x0000;
    //上报心跳
    public static final short CMD_UP_HEART_BEAT = 0x0100;
    //请求鉴权
    public static final short CMD_UP_AUTH= 0x0101;
    //下发鉴权码DATA1 10 01
    public static final short CMD_DOWN_AUTH_CODE= 0x1001;
    //上报认证码DATA2  11 01
    public static final short CMD_UP_AUTH_CODE= 0x1101;
    //通知认证码是否通过10 02
    public static final short CMD_DOWN_AUTH_RESULT= 0x1002;
    //上报设备信息21 01
    public static final short CMD_UP_DEVICE_INFO= 0x2101;
    //鉴权是否通过
    public static final short CMD_DOWN_ALL_RESULT= 0x2002;
    //设备请求断开连接
    public static final short CMD_UP_DISCONNECT= 0x3100;
    //设备请求ota
    public static final short CMD_UP_OTA= 0x4100;
    public static final short CMD_DOWN_CLOSE = (short)0xf0ff;

    //服务器到comet的指令,部分指令代码里没用到（由FromCmdReciver的转发方法原封不动的转给用户了），做个备份
    public static final short CMD_CHANGE_LED_STATE = 0x0f01;//改变灯状态
    public static final short CMD_RESET_LED_STATE = 0x0f02;//重置灯状态
    public static final short CMD_LED_ON = 0x0f04;//定时开灯
    public static final short CMD_LED_OFF = 0x0f05;//定时关灯
    public static final short CMD_OTA_ASK = 0x0f06;//服务器向设备询问是否允许ota
    public static final short CMD_OTA_TRANSFER = 0x0f07;//服务器开始向设备上传ota的rom
    public static final short CMD_OTA_ROM_SIZE = 0x0f08;//ota结束时发送rom大小
    public static final short CMD_DISPATCH = 0x0f09;//转发数据
    public static final short CMD_DISPATCH_INFRARED = 0x0f0a;//转发红外

    //http请求结果key
    public static final String RET_STATE = "state";//状态码
    public static final String RET_MSG= "msg";//错误信息
    public static final String RET_DATA= "data";//成功时返回的数据

   public static final AttributeKey<DeviceId> DEVICE_ATTR_KEY = AttributeKey.newInstance("deviceId");
}
